package net.pws.oos.web.dto;

import net.pws.common.beanutils.BeanUtils;
import net.pws.oos.biz.model.Role;

import org.apache.commons.lang.StringUtils;

public class RoleDto extends Role {

	private static final long serialVersionUID = -894512207286157655L;

	public static RoleDto from(Role role) {
		RoleDto result = new RoleDto();
		BeanUtils.copyProperties(result, role, new String[] { "users" });
		return result;
	}

	public static Role to(RoleDto dto) {
		Role role = new Role();
		BeanUtils.copyProperties(role, dto);
		if (StringUtils.isEmpty(role.getId())) {
			role.setId(null);
		}
		return role;
	}

}
